/*
 * ExceptionHandlerFactory.java
 * Copyright (C) 2007 by Ezequiel Turovetzky
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
package ar.com.botonera.utils;

import ar.com.botonera.Application;
import ar.com.botonera.config.BotoneraManager;

/**
 * Factory de <code>ExceptionHandler</code>s.
 * <br>
 * @author <a href="mailto:ezequielt@epidataconsulting.com">Ezequiel Turovetzky</a>
 * @version 1.0
 */
public final class ExceptionHandlerFactory {

    //~ Static fields/initializers ---------------------------------------------

    /** El ExceptionHandler devuelto por este factory */
    private static ExceptionHandler handler;

    static {
        BotoneraManager bm = BotoneraManager.getInstance();
        String handlerClass = bm.get("ar.com.botonera.exception.handler");

        try {
            handler = (ExceptionHandler)Class.forName(handlerClass).newInstance();
        } catch(Exception e) {
        	Application.getLogger().error("No se pudo instanciar el ExceptionHandler: " + e.getMessage());
        }
    }

    //~ Constructors -----------------------------------------------------------

    /**
     * Esta clase no debe ser instanciada.
     */
    private ExceptionHandlerFactory() {
    }

    //~ Methods ----------------------------------------------------------------

    /**
     * Devuelve una implementaci&oacute;n de la interfaz
     * <code>ar.com.botonera.utils.ExceptionHandler</code>.
     * <br>
     * Dicha implementaci&oacute;n es tomada de la property
     * <code>ar.com.botonera.exception.handler</code> del archivo
     * <code>botonera.properties</code>.
     * @return El <code>ExceptionHandler</code>.
     */
    public static ExceptionHandler getExceptionHandler() {
        return handler;
    }
}
